package com.kaili.basic.service.impl;

import com.kaili.basic.mapper.OpenAccountMapper;
import com.kaili.basic.service.OpenAccountService;
import com.kaili.common.response.CommonStatus;
import com.kaili.common.util.LoginDetailUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import java.util.Date;
import java.util.Map;

/**
 * Created by lsw on 18-7-23.
 */
@Service
public class OpenAccountServiceImpl implements OpenAccountService {

    @Autowired
    private OpenAccountMapper openAccountMapper;

    @Override
    public Boolean addAccount(Map<String,Object> map) {

        Integer createdId = LoginDetailUtils.getCurrentEmployeeId();
        Long accountId = openAccountMapper.autoCreateAccountId();
        //设置账户id
        map.put("accountId",accountId);
        //设置开户行
        map.put("centerId",1);
        //设置余额
        map.put("balance",0.00);
        //警戒余额
        map.put("alarmBalance",0.00);
        //设置创建时间 状态
        map.put("createdTime",new Date());
        //设置更改日期
        map.put("modifyTime",map.get("createdTime"));
        //设置账户状态
        map.put("status",1);
        //标注系统自动创建
        map.put("remark","系统自动创建");
        //创建人修改人
        map.put("createdBy",1);
        map.put("modifyBy",1);
        //自动开新账户
        try {
            openAccountMapper.addAccount(map);
            return true;
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }
}
